﻿@model ScadaWeb.Model.WellModel
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_LayoutForm.cshtml";
}

<form class="layui-form layui-form-pane ok-form" lay-filter="formTest">
    @*一些不需要更新的隐藏字段*@
    @Html.HiddenFor(x => x.Id)
    @Html.HiddenFor(x => x.CreateTime)
    @Html.HiddenFor(x => x.CreateUserId)
    <div class="layui-form-item">
        <label class="layui-form-label">井位编码</label>
        <div class="layui-input-block">
            <input type="text" id="EnCode" name="EnCode" disabled="disabled" placeholder="井位编码" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">井位名称</label>
        <div class="layui-input-block">
            <input type="text" id="WellName" name="WellName" disabled="disabled" placeholder="井位名称" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所在机构</label>
        <div class="layui-input-block">
            <input type="text" id="OrganizeId" name="OrganizeId" disabled="disabled" lay-filter="tree" placeholder="所在机构" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">井类型</label>
        <div class="layui-input-block">
            <select id="WellType" name="WellType" placeholder="井类型" disabled="disabled" class="layui-input">
            </select>

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">X大地坐标</label>
        <div class="layui-input-block">
            <input type="text" name="XZH" id="XZH" placeholder="X大地坐标"  disabled="disabled" class="layui-input" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">Y大地坐标</label>
        <div class="layui-input-block">
            <input type="text" name="YZH" id="YZH" placeholder="Y大地坐标"  disabled="disabled" class="layui-input" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序码</label>
        <div class="layui-input-block">
            <input type="text" name="SortCode" placeholder="排序码" disabled="disabled" autocomplete="off" class="layui-input" value="1" lay-verify="number" maxlength="2">
        </div>
    </div>
    @*增加的IO点参数*@
    <div class="layui-form-item">
        <label class="layui-form-label">采集站/通道</label>

        <div class="layui-input-block">
            <input type="text" id="IO_ServerID" name="IO_ServerID" disabled="disabled" lay-filter="tree2" placeholder="采集站/通道" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">关联设备</label>
        <div class="layui-input-block">
            <select id="IO_DeviceID" name="IO_DeviceID" disabled="disabled" placeholder="请选择关联设备" class="layui-input"></select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">承包商</label>
        <div class="layui-input-block">
            <input type="text" id="Contractor" name="Contractor" disabled="disabled"  placeholder="设备安装承包商" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">井底流压</label>
        <div class="layui-input-block">
            <input type="text" id="IO_DDLY" name="IO_DDLY" disabled="disabled" placeholder="井底流压(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">动液面</label>
        <div class="layui-input-block">
            <input type="text" id="IO_DYM" name="IO_DYM" disabled="disabled" placeholder="动液面(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">井口套压</label>
        <div class="layui-input-block">
            <input type="text" id="IO_JKTY" name="IO_JKTY" disabled="disabled" placeholder="井口套压(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">系统压力</label>
        <div class="layui-input-block">
            <input type="text" id="IO_XTYL" name="IO_XTYL" disabled="disabled" placeholder="系统压力(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">累计产气量</label>
        <div class="layui-input-block">
            <input type="text" id="IO_LJCQL" name="IO_LJCQL" disabled="disabled" placeholder="累计产气量(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">瞬时产气量</label>
        <div class="layui-input-block">
            <input type="text" id="IO_SSCQL" name="IO_SSCQL" disabled="disabled" placeholder="瞬时产气量(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">气体温度</label>
        <div class="layui-input-block">
            <input type="text" id="IO_QTWD" name="IO_QTWD" disabled="disabled" placeholder="气体温度(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">三相功率</label>
        <div class="layui-input-block">
            <input type="text" id="IO_SXGL" name="IO_SXGL" disabled="disabled" placeholder="三相功率(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">累计产水量</label>
        <div class="layui-input-block">
            <input type="text" id="IO_LJCSL" name="IO_LJCSL" disabled="disabled"  placeholder="累计产水量(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">瞬时产水量</label>
        <div class="layui-input-block">
            <input type="text" id="IO_SSCSL" name="IO_SSCSL" disabled="disabled"  placeholder="瞬时产水量(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">冲次</label>
        <div class="layui-input-block">
            <input type="text" id="IO_GTCC" name="IO_GTCC" disabled="disabled" placeholder="冲次(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">示功图冲程</label>
        <div class="layui-input-block">
            <input type="text" id="IO_GTCC1" name="IO_GTCC1" disabled="disabled" placeholder="示功图冲程(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">示功图载荷</label>
        <div class="layui-input-block">
            <input type="text" id="IO_GTZH" name="IO_GTZH" disabled="disabled" placeholder="示功图载荷(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">三相电压</label>
        <div class="layui-input-block">
            <input type="text" id="IO_SXDY" name="IO_SXDY" disabled="disabled" placeholder="三相电压(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">三相电流</label>
        <div class="layui-input-block">
            <input type="text" id="IO_SXDL" name="IO_SXDL" disabled="disabled" placeholder="三相电流(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用电量</label>
        <div class="layui-input-block">
            <input type="text" id="IO_YDL" name="IO_YDL" disabled="disabled" placeholder="用电量(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">变频器频率</label>
        <div class="layui-input-block">
            <input type="text" id="IO_BPQPL" name="IO_BPQPL" disabled="disabled" placeholder="变频器频率(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电机工作电流</label>
        <div class="layui-input-block">
            <input type="text" id="IO_DJGZDL" name="IO_DJGZDL" disabled="disabled" placeholder="电机工作电流(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电机扭矩</label>
        <div class="layui-input-block">
            <input type="text" id="IO_DJNJ" name="IO_DJNJ" disabled="disabled" placeholder="电机扭矩(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电机工作电压</label>
        <div class="layui-input-block">
            <input type="text" id="IO_DJGZDY" name="IO_DJGZDY" disabled="disabled" placeholder="电机工作电压(IO参数名称,可通过数据中心服务商查询，也可以由相应的设备接入商提供)" autocomplete="off" class="layui-input">
        </div>
    </div>
 
     
</form>
<script>
    layui.use(["form", "treeSelect", "okLayer", "okUtils"], function () {
        let treeSelect = layui.treeSelect;
        let ioServerTreeSelect = layui.treeSelect;
        let form = layui.form;
        let okLayer = layui.okLayer;
        let okUtils = layui.okUtils;
        treeSelect.render({
            elem: "#OrganizeId",
            data: "/Permissions/Well/GetOrganizeTreeSelect",
            type: "GET",
            success: function (d) {

                treeSelect.checkNode('tree', "@Model.OrganizeId");
                treeSelect.refresh('tree');

            }
        });
        ioServerTreeSelect.render({
            elem: "#IO_ServerID",
            data: "/Permissions/Well/GetIOServerTreeSelect",
            type: "GET",
            click: function (obj) {
                if (obj.current.id.split("/").length == 2) {

                    $.ajax({
                        type: "GET",
                        url: "/Permissions/Well/GetDeviceSelect",
                        data: { 'serverId': obj.current.id.split("/")[0], 'communicateId': obj.current.id.split("/")[1] },
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            if (result != null) {
                                /**  * 先移除上次追加的选项（不移除的话会一直追加） * */
                                $("#IO_DeviceID >option").each(function () {
                                    var id = $(this).attr("value");
                                    if (id != -1) {
                                        this.remove();
                                    }
                                });
                                

                                layui.form.render("select");
                            }
                        },
                        error: function (xhr, status, errMsg) {
                            alert(errMsg);
                        }
                    });
                }

            },
            success: function (d) {

                ioServerTreeSelect.checkNode('tree2', "@Model.IO_ServerID");
                ioServerTreeSelect.refresh('tree2');

                //加载默认的采集站通道下的设备列表
                var str="@Model.IO_ServerID";
                $.ajax({
                    type: "GET",
                    url: "/Permissions/Well/GetDeviceSelect",
                    data: { 'serverId': str.split("/")[0], 'communicateId': str.split("/")[1] },
                    contentType: "application/json;charset=utf-8",
                    dataType: "json",
                    success: function (result) {
                        if (result != null) {
                            /**  * 先移除上次追加的选项（不移除的话会一直追加） * */
                            $("#IO_DeviceID >option").each(function () {
                                var id = $(this).attr("value");
                                if (id != -1) {
                                    this.remove();
                                }
                            });
                            for (var i = 0; i < result.length; i++) {
                                
                                   
                                    $("#IO_DeviceID").append("<option value='" + result[i].id + "'>" + result[i].name + "</option>");
                              

                            }
                            $("#IO_DeviceID").val("@Model.IO_DeviceID");
                            layui.form.render("select");
                        }
                    },
                    error: function (xhr, status, errMsg) {
                        alert(errMsg);
                    }
                });

            }
        });
        //加载井类型
        $.get("/Permissions/Well/GetWellType?EnCode=WellType", function (result) {


            for (var i = 0; i < result.length; i++) {

                $("#WellType").append("<option value='" + result[i].id + "'>" + result[i].name + "</option>");
            }

            $("#WellType").val(@Model.WellType);
            layui.form.render("select");


        });
        //给表单赋值
        form.val("formTest", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
            "EnCode": "@Model.EnCode",
            "WellName": "@Model.WellName",
            "SortCode": "@Model.SortCode",
            "OrganizeId": "@Model.OrganizeId",
            "WellType": "@Model.WellType",
            "IO_DeviceID": "@Model.IO_DeviceID",
            "IO_DDLY": "@Model.IO_DDLY",
            "IO_DYM": "@Model.IO_DYM",
            "IO_JKTY": "@Model.IO_JKTY",
            "IO_XTYL": "@Model.IO_XTYL",
            "IO_LJCQL": "@Model.IO_LJCQL",
            "IO_SSCQL": "@Model.IO_SSCQL",
            "IO_QTWD": "@Model.IO_QTWD",
            "IO_SXGL": "@Model.IO_SXGL",
            "IO_LJCSL": "@Model.IO_LJCSL",
            "IO_SSCSL": "@Model.IO_SSCSL",
            "IO_GTCC": "@Model.IO_GTCC",
            "IO_GTCC1": "@Model.IO_GTCC1",
            "IO_GTZH": "@Model.IO_GTZH",
            "IO_SXDY": "@Model.IO_SXDY",
            "IO_SXDL": "@Model.IO_SXDL",
            "IO_YDL": "@Model.IO_YDL",
            "IO_BPQPL": "@Model.IO_BPQPL",
            "IO_DJGZDL": "@Model.IO_DJGZDL",
            "IO_DJNJ": "@Model.IO_DJNJ",
            "IO_DJGZDY": "@Model.IO_DJGZDY",
            "XZH": "@Model.XZH",
            "YZH": "@Model.YZH",
        });
      
    });
</script>

